package com.tianhui.consignortwofei.mvp.ui.activity.hetong;

import android.widget.FrameLayout;

import com.fgs.common.CommonFragment;
import com.fgs.common.CommonPresenter;
import com.fgs.common.CommonView;
import com.fgs.common.adapter.FragmentPagerAdapter;
import com.fgs.common.utils.LogUtil;
import com.fgs.common.widget.CustomViewPager;
import com.flyco.tablayout.SlidingTabLayout;
import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.base.BaseActivity;
import com.tianhui.consignortwofei.base.BaseFragment;
import com.tianhui.consignortwofei.jPush.PushMessageReceiver;
import com.tianhui.consignortwofei.manager.SharedPreferenceManager;
import com.tianhui.consignortwofei.mvp.ui.activity.ShenHeTongJiActivity;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.impl.ShenContractStatusHeTong;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.impl.YiShenContractStatusHeTong;
import com.tianhui.consignortwofei.utils.BadgerUtil;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import butterknife.BindView;
import me.leolin.shortcutbadger.ShortcutBadger;

/**
 * @author fgs
 * @date 2020/4/28
 * @description
 **/
public class HeTongShenTwoActivity extends BaseActivity {

    @BindView(R.id.activity_order_list_viewPager)
    CustomViewPager mViewPager;
    @BindView(R.id.activity_order_list_slidingTabLayout)
    SlidingTabLayout mTabLayout;
    @BindView(R.id.activity_order_list_TabFrameLayout)
    FrameLayout mTabFrameLayout;


    private List<CommonFragment> mFragmentList = new ArrayList<>();
    private FragmentPagerAdapter mPagerAdapter;
    private int rolePosition;
    private int type=0;

    @Override
    public int getLayoutId() {
        return R.layout.activity_all_order_goods;
    }

    @Override
    public CommonPresenter createPresenter() {
        return null;
    }

    @Override
    public CommonView createView() {
        return null;
    }

    @Override
    public void init() {
        setTitle("销售合同管理");
        setSubTitle("合同统计");


//        Bundle bundle = getIntent().getExtras();
//        if (bundle != null && !bundle.isEmpty()) {
//            type = bundle.getInt("type");
//
//        }
        //清除角标
        try {
            PushMessageReceiver.msgNum=0;
            ShortcutBadger.removeCount(this);
            BadgerUtil.addBadger(this, 0);
        }catch (Exception e){
            LogUtil.print(e.toString());
        }


        rolePosition = SharedPreferenceManager.getInstance().getRolePosition();
        createFragmentListTwo();
        List<String>  tablist = Arrays.asList(getResources().getStringArray(R.array.array_my_goods_list));
        mTabLayout.setTabSpaceEqual(true);

//        mPagerAdapter = new FragmentPagerAdapter(getFragmentManager());
        mPagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager());

        mPagerAdapter.setFragments(mFragmentList);
        mViewPager.setCanScroll(false);
        mViewPager.setHasEffect(false);
        mViewPager.setOffscreenPageLimit(mFragmentList.size());
        mViewPager.setAdapter(mPagerAdapter);

        mPagerAdapter.setTabTitles(tablist);
        mTabLayout.setViewPager(mViewPager);

//        switch (type){
//            case 0:
//                setCurrentItem(0);
//                break;
//            case 1:
//                setCurrentItem(1);
//                break;
//            case 2:
//                setCurrentItem(2);
//                break;
//            case 3:
//                setCurrentItem(3);
//                break;
//            case 4:
//                setCurrentItem(4);
//                break;
//        }



    }

    @Override
    public BaseFragment createFragment() {
        return null;
    }

//    @OnClick(R.id.activity_about_versionUpdateSettingItemView)
//    public void versionUpdate() {
//        updateCheck();
//    }



    private List<CommonFragment> createFragmentListTwo() {

        mFragmentList.add(new ShenContractListFragment().setOrderStatus(new ShenContractStatusHeTong()));
        mFragmentList.add(new ShenContractListFragment().setOrderStatus(new YiShenContractStatusHeTong()).setWitch("1"));
//        mFragmentList.add(new ShopMyGoodsListFragment("2"));
//        mFragmentList.add(new ShopMyGoodsListFragment("3"));
//        mFragmentList.add(new ShopMyGoodsListFragment("4"));

        return mFragmentList;
    }

    private void setCurrentItem(int item) {
        mViewPager.setCurrentItem(item);
    }


    @Override
    public void onSubtitleClick() {
        openActivity(ShenHeTongJiActivity.class);

    }


}
